<?php

/**
 * Powerdev form base class.
 *
 * @method Powerdev getObject() Returns the current form's model object
 *
 * @package    seth
 * @subpackage form
 * @author     Fuz
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BasePowerdevForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'       => new sfWidgetFormInputHidden(),
      'plant'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Plant'), 'add_empty' => false)),
      'subplant' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Subplant'), 'add_empty' => true)),
      'brand'    => new sfWidgetFormInputText(),
      'model'    => new sfWidgetFormInputText(),
      'serial'   => new sfWidgetFormInputText(),
      'type'     => new sfWidgetFormInputText(),
      'subtype'  => new sfWidgetFormInputText(),
      'power'    => new sfWidgetFormInputText(),
      'quantity' => new sfWidgetFormInputText(),
      'label'    => new sfWidgetFormInputText(),
      'source'   => new sfWidgetFormInputText(),
      'address'  => new sfWidgetFormInputText(),
      'source2'  => new sfWidgetFormInputText(),
      'address2' => new sfWidgetFormInputText(),
      'note'     => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'       => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'plant'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Plant'))),
      'subplant' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Subplant'), 'required' => false)),
      'brand'    => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'model'    => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'serial'   => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'type'     => new sfValidatorString(array('max_length' => 45)),
      'subtype'  => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'power'    => new sfValidatorNumber(array('required' => false)),
      'quantity' => new sfValidatorInteger(),
      'label'    => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'source'   => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'address'  => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'source2'  => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'address2' => new sfValidatorString(array('max_length' => 45, 'required' => false)),
      'note'     => new sfValidatorString(array('max_length' => 255, 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('powerdev[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Powerdev';
  }

}
